import pandas as pd

from app_config import get_engine_ts, get_pro

engine_ts = get_engine_ts()


# def read_data():
#     sql = """SELECT * FROM fund_basic_e"""
#     df = pd.read_sql_query(sql, engine_ts)
#     return df
#

def write_data(df):
    res = df.to_sql('fund_basic_e', engine_ts, index=False, if_exists='append', chunksize=5000)
    print(res)


def get_data():
    data = get_pro().fund_basic(market='E')
    return data

if __name__ == '__main__':
    #     df = read_data()
    df = get_data()
    write_data(df)
    print(df)
